﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
@* <script src="~/lib/layui/layui.js"></script> *@
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>待检任务</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <form class="layui-form layui-row layui-col-space16" action="">
        <div class="layui-col-xs3">
            <div class="layui-input-group">
                <div class="layui-input-prefix"><b>单据编码:</b> </div>
                <input type="text" id="signingNo" value="" placeholder="请输入工单编码" class="layui-input" lay-affix="clear">
            </div>
        </div>
        <div class="layui-col-xs3">
            <div class="layui-input-group">
                <div class="layui-input-prefix"><b>物料名称:</b> </div>
                <input type="text" id="proName" value="" placeholder="请输入工单编码" class="layui-input" lay-affix="clear">
            </div>
        </div>
        <div class="layui-col-xs3">
            <div class="layui-input-group">
                <div class="layui-input-prefix"><b>检测类型:</b> </div>
                <input type="text" id="toBeInspectedType" value="" placeholder="请输入工单编码" class="layui-input" lay-affix="clear">
            </div>
        </div>
        <div class="layui-col-xs3">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo-table-search">搜索</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <table class="layui-hide" id="ID-table-demo-search" style="margin-top:50px"></table>
    <div id="demo-laypage-all"></div>
    <script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
    <script>
        layui.use(function () {
            var table = layui.table;
            var $ = layui.$;
            var form = layui.form;
            var laydate = layui.laydate;
            var util = layui.util;
            var layer = layui.layer;
            var laypage = layui.laypage;
            var tree = layui.tree;
            var pageIndex = 1;
            var pageSize = 3;
            getList(pageIndex, pageSize);

            function getList(pageIndex, pageSize) {
                let obj = {
                    signingNo: $("#signingNo").val(),
                    proName: $("#proName").val(),
                    toBeInspectedType: $("#toBeInspectedType").val(),
                    pageIndex: pageIndex,
                    pageSize: pageSize
                }
                table.render({
                    elem: '#ID-table-demo-search',
                    method: 'POST',
                    contentType: 'application/json',
                    url: '@ViewBag.FoundationRead' + '/api/WorkOrders/InspectedList',
                    where: obj,// 此处为静态模拟数据，实际使用时需换成真实接口
                    cols: [[
                        { type: 'checkbox', fixed: 'left' },
                        { field: 'signingNo', title: '来源单据编号', sort: true, fixed: true },
                        { field: 'toBeInspectedType', title: '检测项型', width: 80 },
                        { field: 'productsNo', title: '物资编码', sort: true },
                        { field: 'productManageName', title: '物资名称' },
                        { field: 'toBeInspectedNumber', title: '待检数量' },
                        { field: 'address', title: '位置', sort: true }
                    ]],
                    page: false,
                    height: 310,
                    done: function (res) {
                        var id = this.id;
                        console.log(res);// 你可以在这里检查返回的数据结构是否符合预期
                        // 触发单元格工具事件
                        //分页数据
                        laypage.render({
                            elem: 'demo-laypage-all', // 元素 id
                            count: res.totalCount, // 数据总数
                            curr: pageIndex,
                            limit: pageSize,
                            limits: [2, 3, 4],
                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                            jump: function (obj, first) {
                                if (!first) {
                                    getList(obj.curr, obj.limit);
                                }
                            }
                        });
                    }
                });
            }
            // 创建表格实例

            // 日期
            laydate.render({
                elem: '.demo-table-search-date'
            });
            // 搜索提交
            form.on('submit(demo-table-search)', function (data) {
                getList(pageIndex, pageSize);
                return false; // 阻止默认 form 跳转
            });
        });
    </script>
</body>
</html>